import request from '@/utils/request'

// 获取标签分类树 -- 一维平铺
export const getTreeSelectorByAuth = (id: any) => {
    return request({
        url: '/data-labels/labellevel/getLabelTrees',
        method: 'get'
    })
}

// 标签树节点修改
export const updateLabelTreeNode = (params: any) => {
    if (params.id) {

        return request({
            url: '/data-labels/labellevel/update',
            method: 'POST',
            data: params,
        })
    } else {
        return request({
            url: '/data-labels/labellevel/save',
            method: 'POST',
            data: params,
        })
    }
}

// 删除标签树节点
export const delTreeNode = (params: any) => {
    return request({
        url: `/data-labels/labellevel/delete`,
        method: 'POST',
        data: params
    })
}

// 获取基础标签列表
export const getLabelList = (params: any) => {
    return request({
        url: '/data-labels/labelstorage/page',
        method: 'POST',
        data: params,
    })
}

// 标签删除
export const delLabelObj = (id: any) => {
    return request({
        url: `/data-labels/labelstorage/label_delete/${id}`,
        method: 'get',
    });
}

// 标签详情
export const getLabelDetail = (data: any) => {
    return request({
        url: '/data-labels/labelfun/getCheckDetail',
        method: 'POST',
        data: data
    });
}


// 标签保存
export const saveLabel = (data: any) => {
    if (data.bqid) {
        return request({
            url: '/data-labels/labelstorage/primary_label_update',
            method: 'POST',
            data: data,
        })
    } else {

        return request({
            url: '/data-labels/labelstorage/primary_label_save',
            method: 'POST',
            data: data,
        });
    }
}


// 动态sql测试
export const actionSql = (data: any) => {
    return request({
        url: '/data-labels/labelstorage/test-sql',
        method: 'POST',
        data: data,
    });
}

// 标签列表页 立即执行
export const immediateActionSql = (params: any) => {
    return request({
        url: '/data-labels/labelstorage/updateLabelObjectOnes',
        method: 'POST',
        data: params,
    });
}

// 标签审核
export const labelcheck = (data: any, type: any) => {
    if (type) { // 基础
        return request({
            url: '/data-labels/labelstorage/check',
            method: 'POST',
            data: data,
        });
    } else { //组合
        return request({
            url: '/data-labels/labelcombination/check',
            method: 'POST',
            data: data,
        });
    }
}

// 组合
// 组合标签详情
export const combinationDetail = (params: any) => {
    return request({
        url: '/data-labels/labelcombination/view',
        method: 'POST',
        data: params,
    })
}

// 组合标签删除
export const combinationDelete = (params: any) => {
    return request({
        url: '/data-labels/labelcombination/delete',
        method: 'POST',
        data: params,
    })
}

// 组合标签新增
export const combinationAdd = (data: any) => {
    return request({
        url: '/data-labels/labelcombination/save',
        method: 'POST',
        data: data,
    })
}

// 组合标签保存修改
export const combinationSave = (data: any) => {
    if (data.zhbh) {
        return request({
            url: '/data-labels/labelcombination/update',
            method: 'POST',
            data: data,
        })
    } else {

        return request({
            url: '/data-labels/labelcombination/save',
            method: 'POST',
            data: data,
        })
    }
}

// 组合标签列表
export const combinationList = (params: any) => {
    return request({
        url: '/data-labels/labelcombination/page',
        method: 'POST',
        data: params,
    })
}

// 组合标签 立即执行
export const combinationExecute = (params: any) => {
    return request({
        url: '/data-labels/labelcombinationobject/updateCombinationObjectOnes',
        method: 'POST',
        data: params,
    })
}


// 审核记录
export const getProcessList = (params: any) => {
    return request({
        url: '/data-labels/labelstorage/examineRecords',
        method: 'post',
        data: params,
    });
}

// 新增审核
export const addProcess = (params: any, type: any) => {
    if (type) { // 基础
        return request({
            url: '/data-labels/labelstorage/check',
            method: 'POST',
            data: params,
        });
    } else {
        return request({
            url: '/data-labels/labelcombination/check',
            method: 'POST',
            data: params,
        });
    }
}

// 组合标签停用审核
export const combinationStop = (params: any) => {
    return request({
        url: '/data-labels/labelcombination/combinationCheck',
        method: 'POST',
        data: params,
    });
}

// 基础标签停用审核
export const stopProcess = (params: any) => {
    return request({
        url: '/data-labels/labelstorage/check_label',
        method: 'POST',
        data: params,
    });
}

// 获取所有的标签数据
export const getLabelListAll = () => {
    return request({
        url: '/data-labels/labelstorage/get_label_list',
        method: 'get'
    });
}

// 获取数据库
export const getLabelSqlList = () => {
    return request({
        url: '/data-integrate/database',
        method: 'get',
    });
}

// 获取数据表
export const getTableList = (id: any) => {
    return request({
        url: `/data-integrate/database/tables/${id}`,
        method: 'get',
    });
}

// 获取表字段
export const getTableColumns = (id: any, tableName: any) => {
    return request({
        url: `/data-integrate/database/${id}/${tableName}/columns`,
        method: 'get',
    })
}